﻿using AppFramework;
using AppFramework.DinosaursParkMes.Production.DTO;
using AppFramework.DinosaursParkMes.ProductionReturn;
using AppFramework.DinosaursParkMes.ProductionReturn.DTO;
using AppFramework.DinosaursParkMes.UniqueIdCode.Dto;
using AppFramework.DinosaursParkMes.UniqueIdCode;
using AppFramework.Localization.Dto;
using AppFramework.Organizations.Dto;
using AppFramework.Shared;
using Models.DinosaursParkMes.Production;
using Models.DinosaursParkMes.ProductionReturn;
using Prism.Commands;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Media.Media3D;

namespace ViewModels.DinosaursParkMes.ProductionReturn
{
    public class ProductionReturnAddViewModel: HostDialogViewModel
    {
        private readonly IProductionReturninfoAppService appservice;
        private readonly ProductionReturninfoAppService service;
        public  ProductionReturninfo productionReturninfo;
        public  ProductionReturnRequestDTO request;
        
        public ProductionReturnAddViewModel(IProductionReturninfoAppService appservice, ProductionReturninfoAppService service=null, ProductionReturninfo productionReturninfo = null, ProductionReturnRequestDTO request = null)
        {
            this.appservice = appservice;
            this.service = service;
            this.productionReturninfo = productionReturninfo;
            this.request = request;
            
        }



        
        public ProductionReturninfo Models
        {
            get { return productionReturninfo; }
            set { productionReturninfo = value; OnPropertyChanged(); }
        }
        /// <summary>
        /// 重写添加
        /// </summary>
        /// <returns></returns>
        public override async Task Save()
        {
            await SetBusyAsync(async () =>
            {
                var dto = Map<ProductionReturnRequestDTO>(Models);
                //await WebRequest.Execute(async () =>
                //{
                //    await appservice.AddProductionReturn(dto);
                //}, base.Save);
                await appservice.AddProductionReturn(dto).WebAsync();

            });
        }
        
        
        public override void OnDialogOpened(IDialogParameters parameters)
        {
            throw new NotImplementedException();
        }

    }
}
